package com.xindacloud.sms.console.system.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xindacloud.sms.console.result.Result;
import com.xindacloud.sms.console.result.ResultGenerator;
import com.xindacloud.sms.console.system.dto.SmsReceiveEmailSettingDTO;
import com.xindacloud.sms.console.system.entity.SmsAgent;
import com.xindacloud.sms.console.system.entity.SmsReceiveEmailSetting;
import com.xindacloud.sms.console.system.mapper.SmsReceiveEmailSettingMapper;
import com.xindacloud.sms.console.system.service.ISmsReceiveEmailSettingService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author czc
 * @since 2019-10-15
 */
@Service
public class SmsReceiveEmailSettingServiceImpl extends ServiceImpl<SmsReceiveEmailSettingMapper, SmsReceiveEmailSetting> implements ISmsReceiveEmailSettingService {

	@Override
	public Result getSmsReceiveEmailSettingList(SmsReceiveEmailSettingDTO smsReceiveEmailSettingDTO) {
		IPage<SmsReceiveEmailSetting> page=new Page<>(smsReceiveEmailSettingDTO.getPageNum(),smsReceiveEmailSettingDTO.getPageSize());
		QueryWrapper<SmsReceiveEmailSetting> queryWrapper=new QueryWrapper<>();
		if(smsReceiveEmailSettingDTO.getContacts()!=null) {
		queryWrapper.eq("contacts", smsReceiveEmailSettingDTO.getContacts());
		}
		return ResultGenerator.genSuccessResult(this.page(page,queryWrapper));
	}

	@Override
	public Result saveOrUpdateSmsReceiveEmailSetting(SmsReceiveEmailSetting smsReceiveEmailSetting) {
		if(this.saveOrUpdate(smsReceiveEmailSetting)){
		    return ResultGenerator.genSuccessResult("保存或修改成功！");
		}else {
			return ResultGenerator.genClientFailResult("保存或修改失败！");
		}
	}

}
